﻿<UserControl x:Class="MaxStoreErp.Shell.MainMenu.MainMenuView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mainMenu="clr-namespace:MaxStoreErp.Shell.MainMenu"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             d:DataContext="{d:DesignInstance mainMenu:MainMenuViewModel}"
             d:DesignHeight="300"
             d:DesignWidth="300"
             mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/MahApps.Metro;component/Themes/Tile.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style x:Key="Heading2" TargetType="TextBlock">
                <Setter Property="FontFamily" Value="Segoe UI" />
                <Setter Property="FontSize" Value="16" />
                <Setter Property="FontWeight" Value="Bold" />
                <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
            </Style>

            <CollectionViewSource x:Key="Data" Source="{Binding MenuItems}">
                <CollectionViewSource.GroupDescriptions>
                    <PropertyGroupDescription PropertyName="GroupName" />
                </CollectionViewSource.GroupDescriptions>
            </CollectionViewSource>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid Background="Bisque">
        <ItemsControl ItemsSource="{Binding Source={StaticResource Data}}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <xctk:WrapPanel IsHitTestVisible="True" Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.GroupStyle>
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="GroupItem">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="GroupItem">
                                        <GroupBox BorderThickness="0,0,0,0" Header="{Binding Name}">
                                            <GroupBox.HeaderTemplate>
                                                <DataTemplate>
                                                    <TextBlock Style="{StaticResource Heading2}" Text="{Binding}" />
                                                </DataTemplate>
                                            </GroupBox.HeaderTemplate>
                                            <ItemsPresenter />
                                        </GroupBox>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </ItemsControl.GroupStyle>
        </ItemsControl>
    </Grid>
</UserControl>
